<!DOCTYPE html>
<html lang="en">
<head>
    <base href="${request.contextPath}/"/>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <#import "/spring.ftl" as spring>
    <title><@spring.message code="index.top"/></title>

    <script src="${request.contextPath}/js/jquery-1.11.1.min.js"></script>
    <script src="${request.contextPath}/js/common_click.js"></script>
    <script src="${request.contextPath}/js/echarts.min.js"></script>
    <link rel="stylesheet" href="${request.contextPath}/css/common.css">
    <link rel="stylesheet" href="${request.contextPath}/css/jzny.css">
    <link rel="stylesheet" href="${request.contextPath}/lib/jqueryPagination/css/jquery.pagination.css"/>
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script src="${request.contextPath}/lib/jqueryPagination/js/jquery.pagination.min.js"></script>
    <#setting date_format="yyyy-MM-dd HH:mm:ss">

</head>
<body>
<div class="top_all">
    <p class="top_title"><@spring.message code="index.top"/></p>
    <div class="top_user" >
        <#if isAdmn == "TRUE">
        <div class="top_user_img" style="margin-top: 20px;margin-left: 20px;">
            <img src="${request.contextPath}/images/timg.png" alt="">

        </div>

        <a href="javascript:;" onclick="shouye()">
            <p class="top_user_name" style="margin-top: 20px;"><@spring.message code="index.page"/></p>
        </a>
    </#if>

    </div>


    <div class="top_out">
        <div class="out_out">
            <div class="top_out_img">
                <img src="images/icon.png" alt="">

            </div>
            <a href="${request.contextPath}/sy/logout">
                <p class="top_out_name"><@spring.message code="index.out"/></p>
            </a>
        </div>

    </div>


</div>

<input type="hidden" name="landid" id="landid" value="${landid}">
<div class="content_all">
    <div class="content">
        <div class="content_left">
            <div class="content_left_1">
                <div class="content_left_1_title"><@spring.message code="jzny.ssjl"/></div>
                <div class="content_left_1_content_all">
                    <div class="content_left_1_content">
                        <div class="content_data">
                            <div class="content_data_left" style="background:#0D96F1"><@spring.message code="jzny.fx"/></div>
                            <div class="content_data_right">${jznyLast.windDirection}</div>
                        </div>
                        <div class="content_data">
                            <div class="content_data_left" style="background:#0ED844"><@spring.message code="jzny.fs"/></div>
                            <div class="content_data_right">${jznyLast.windSpeed}</div>
                        </div>
                        <div class="content_data">
                            <div class="content_data_left" style="background:#FCBC00"><@spring.message code="jzny.yl"/></div>
                            <div class="content_data_right">${jznyLast.rainfall}</div>
                        </div>
                        <div class="content_data">
                            <div class="content_data_left" style="background:#F77912"><@spring.message code="jzny.kqwd"/></div>
                            <div class="content_data_right">${jznyLast.airTemperature}</div>
                        </div>
                        <div class="content_data">
                            <div class="content_data_left" style="background:#DF28EC"><@spring.message code="jzny.kqsd"/></div>
                            <div class="content_data_right">${jznyLast.airHumidity}</div>
                        </div>
                        <div class="content_data">
                            <div class="content_data_left" style="background:#6E03F6"><@spring.message code="jzny.trwd"/></div>
                            <div class="content_data_right">${jznyLast.soilTemperature}</div>
                        </div>
                        <div class="content_data">
                            <div class="content_data_left" style="background:#019FD4"><@spring.message code="jzny.trsd"/></div>
                            <div class="content_data_right">${jznyLast.soilMoisture}</div>
                        </div>
                        <div class="content_data">
                            <div class="content_data_left" style="background:#FCBC00"><@spring.message code="jzny.gzqd"/></div>
                            <div class="content_data_right">${jznyLast.lightIntensity}</div>
                        </div>
                        <div class="content_data">
                            <div class="content_data_left" style="background:#0D96F1"><@spring.message code="jzny.CO2nd"/></div>
                            <div class="content_data_right">${jznyLast.cO2concentration}</div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="content_left_2">
                <div class="content_left_1_title"><@spring.message code="jzny.sjqx"/></div>
                <div id="main" class="content_left_2_content">


                    <script type="text/javascript">
                        if (screen.width > 1919)
                            document.write('<script type="text/javascript" src="js/jzny_echarts_1920.js"><\/script>');
                        if (screen.width < 1919) {
                            document.write('<script type="text/javascript" src="js/jzny_echarts_1440.js"><\/script>');
                        }
                    </script>


                </div>
            </div>
        </div>
        <input type="hidden" name="current" id="current" value="1">
        <input type="hidden" name="titleNum" id="titleNum" value="${titleNum}">

        <div class="content_right">
            <div class="content_right_one">
                <div class="content_right_one_title"><@spring.message code="jzny.lsjl"/></div>
                <div class="content_right_one_content" id="tablediv">
                    <!--<table class="content_right_one_content_table">-->
                    <table class="content_right_one_content_table" id="mytable">
                        <tr>
                            <td></td>
                            <td><@spring.message code="jzny.fx"/></td>
                            <td><@spring.message code="jzny.fs"/></td>
                            <td><@spring.message code="jzny.yl"/></td>
                            <td><@spring.message code="jzny.kqwd"/></td>
                            <td><@spring.message code="jzny.kqsd"/></td>
                            <td><@spring.message code="jzny.trwd"/></td>
                            <td><@spring.message code="jzny.trsd"/></td>
                            <td><@spring.message code="jzny.gzqd"/></td>
                            <td><@spring.message code="jzny.CO2nd"/></td>
                        </tr>
                        <#list jznyAllPage as jzny>
                        <tr>
                            <td>${(jzny.createtime?date)!""}</td>
                            <td>${jzny.windDirection}</td>
                            <td>${jzny.windSpeed}（m/s）</td>
                            <td>${jzny.rainfall}（mm/min）</td>
                            <td>${jzny.airTemperature}℃</td>
                            <td>${jzny.airHumidity}%</td>
                            <td>${jzny.soilTemperature}℃</td>
                            <td>${jzny.soilMoisture}%</td>
                            <td>${jzny.lightIntensity}klux</td>
                            <td>${jzny.cO2concentration}ppm</td>
                        </tr>
                        </#list>
                    </table>
                </div>
                <div class="content_right_one_bottom">
                    <div class="box">
                        <div id="pagination3" class="page fl"></div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<div class="footer_all"></div>

<script src="${request.contextPath}/js/jzny.js"></script>

</body>
<script>
    function shouye(){
        var req = new XMLHttpRequest();
        req.open('GET', document.location, false);
        req.send(null);
        var headers = req.getAllResponseHeaders();
        var local=req.getResponseHeader('content-language');
        if(local=="en-US"){
            local="en_US";
        }else{
            local="zh_CN";
        }
        //alert(local+"-----"+"en_US");
        window.location.href="${request.contextPath}/sy/index/index?locale="+local;
    }
</script>
<script>
    var landid = $("#landid").val();
    $(function () {
        $("#pagination3").pagination({
            currentPage: 1,
            totalPage: 6,
            isShow: true,
            count: 10,
            homePageText: "<@spring.message code='index.page'/>",
            endPageText: "<@spring.message code='zjwd.wy'/>",
            prevPageText: "<@spring.message code='zjwd.syy'/>",
            nextPageText: "<@spring.message code='zjwd.xyy'/>",
            callback: function (current) {
                tiaozhuan(current);
            }
        });
        var current = $('#current').val() - 0;
        var titleNum = $('#titleNum').val() - 0;
        $("#pagination3").pagination("setPage", current, titleNum);
    });

    function tiaozhuan(current) {
        $.ajax({
            type: "post",
            async: true, //异步执行
            url: "${request.contextPath}/sy/jzny/jznypage?current=" + current+"&landid="+landid,
            dataType: "json", //返回数据形式为json
            success: function (json1) {
                var json = $.parseJSON(json1);
                $("#tablediv").html("");
                $("#current").val(json.current);
                $("#titleNum").html(json.titleNum);
                var dataObj = json.jznyAllPage;

                var con = " <table class=\"content_right_one_content_table\" id=\"mytable\">\n" +
                    "                        <tr>\n" +
                    "                            <td></td>\n" +
                    "                            <td><@spring.message code='jzny.fx'/></td>\n" +
                    "                            <td><@spring.message code='jzny.fs'/></td>\n" +
                    "                            <td><@spring.message code='jzny.yl'/></td>\n" +
                    "                            <td><@spring.message code='jzny.kqwd'/></td>\n" +
                    "                            <td><@spring.message code='jzny.kqsd'/></td>\n" +
                    "                            <td><@spring.message code='jzny.trwd'/></td>\n" +
                    "                            <td><@spring.message code='jzny.trsd'/></td>\n" +
                    "                            <td><@spring.message code='jzny.gzqd'/></td>\n" +
                    "                            <td><@spring.message code='jzny.CO2nd'/></td>\n" +
                    "                        </tr>";
                $.each(dataObj, function (index, item) {
                    var newTime = getMyDate(item.createtime);
                    con +="<tr>\n" +
                        "<td>"+newTime+"</td>\n" +
                        "<td>"+item.windDirection+"</td>\n" +
                        "<td>"+item.windSpeed+"（m/s）</td>\n" +
                        "<td>"+item.rainfall+"（mm/min）</td>\n" +
                        "<td>"+item.airTemperature+"℃</td>\n" +
                        "<td>"+item.airHumidity+"%</td>\n" +
                        "<td>"+item.soilTemperature+"℃</td>\n" +
                        "<td>"+item.soilMoisture+"%</td>\n" +
                        "<td>"+item.lightIntensity+"klux</td>\n" +
                        "<td>"+item.cO2concentration+"ppm</td>\n" +
                        "</tr>"

                });
                con+=" </table> ";
                $("#tablediv").html(con);
                $(".content_right_one_content_table tr").eq(0).addClass("content_right_one_content_table_header")
                // $(".content_right_one_content_table tr td").first().addClass("content_right_one_content_table_time")

                $(".content_right_one_content_table tr").each(function(){
                    $(this).find("td:first").addClass("content_right_one_content_table_time");
                })
                $("td:not(.content_right_one_content_table_time,.content_right_one_content_table_header td)").addClass("content_right_one_content_table_td_border");


                $(".content_right_one_content_table tr:last").find("td"). removeClass("content_right_one_content_table_td_border")
            },
            error: function (errorMsg) {
                alert("请求数据失败");
            }
        });
    }
    function getMyDate(str){
        var oDate = new Date(str),
            oYear = oDate.getFullYear(),
            oMonth = oDate.getMonth()+1,
            oDay = oDate.getDate(),
            oHour = oDate.getHours(),
            oMin = oDate.getMinutes(),
            oSen = oDate.getSeconds(),
            oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);//最后拼接时间
            //oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay);
        return oTime;
    };
    function getzf(num){
        if(parseInt(num) < 10){
            num = '0'+num;
        }
        return num;
    }
</script>
<script>
    $(function () {



        $(".button_click").eq(0).css({backgroundColor: "#43D3FF"})
        $(".button_click").eq(0).children("a").css({color: "#1921BB"})


    })
</script>
<script>

    var zlzs='<@spring.message code="menu.zlzs"/>';
    var zjwd='<@spring.message code="menu.zjwd"/>';
    var nybk='<@spring.message code="menu.nybk"/>';
    var nydsj='<@spring.message code="menu.nydsj"/>';


</script>
</html>




